chore(lint): exclude goconst from test files - #55
Closed
bfirestone wants to merge 1 commit into
Closed
Conversation
Test fixtures intentionally repeat literals (status strings, IDs, paths)
as self-contained sample data — DAMP (Descriptive And Meaningful Phrases)
over DRY. Extracting them into constants hurts test readability without
the single-source-of-truth payoff that goconst targets in production code.
This mirrors the existing dupl exclusion for _test.go ("Test files often
have similar structures for readability"). Newer golangci-lint versions
surface goconst on test files; this keeps that noise out consistently.
Contributor
Author
|
Superseded by #54, which already added a goconst exclusion for test files in .golangci.yaml (and bumped CI to golangci-lint v2.12.2 with tree-wide fixes). This change is now redundant. Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
goconstexclusion for_test.gofiles in.golangci.yaml, placed alongside the existingduplexclusion.Why
Test fixtures intentionally repeat literals (status strings, IDs, transcript paths) as self-contained sample data — DAMP (Descriptive And Meaningful Phrases) over DRY. Hoisting fixture strings into constants forces readers to jump away from a test to learn what a row contains, and there's no single-source-of-truth payoff the way there is for production logic — which is what
goconstis actually for.This mirrors the decision already made for the
dupllinter, which is excluded from_test.gowith the comment "Test files often have similar structures for readability."goconstis the same category of duplication-in-tests-is-fine.Newer
golangci-lintversions (≥ v2.12) surfacegoconston test files (~50 hits acrossinternal/types,internal/storage/sqlite,internal/clienttest fixtures); this keeps that noise out consistently, independent of linter version.Scope
Config-only change. No production code or tests modified. Where a test literal genuinely mirrors a production domain constant (e.g. a status value), referencing the existing
typesconstant is still encouraged — that's drift protection, not covered here.